<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <link href="../css/swiper.min.css" rel="stylesheet"/>
    <style>
    .x-ico-month .el-input__inner{
      border: 0;
      font-size: 1rem;
      text-align: center;
    }.x-ico-month .el-input__prefix{
      display: none;
    }.el-dialog .el-input__inner{
      border: 1px solid #ccc;
    }
    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">调拨验收</div>
      </div>
 
        <div class="">
          <template>
            <el-table :data="tabledata" @cell-click="gotrainpro">
              <el-table-column label="品名" width="90" fixed>
                <template slot-scope="scope">
                  {{scope.row.title}}
                </template>
              </el-table-column>
              <el-table-column label="存规格" width="">
                <template slot-scope="scope">
                  {{scope.row.save_unit}}
                </template>
              </el-table-column>
              <el-table-column label="审核量" width="">
                <template slot-scope="scope">
                  {{scope.row.check_num}}
                </template>
              </el-table-column>
              <el-table-column label="验收量" width="">
                <template slot-scope="scope">
                  <div v-if="noget=='0'" style="border:1px solid #058142;border-radius:.2rem;"><el-input v-model="scope.row.save_num" placeholder="请输入内容" type="number"></el-input></div>
                  <div v-else>
                    {{scope.row.save_num}}
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="单价" width="">
                <template slot-scope="scope">
                  {{scope.row.unit_price}}
                </template>
              </el-table-column>
              <el-table-column label="金额" width="">
                <template slot-scope="scope">
                  {{(scope.row.save_num*scope.row.unit_price).toFixed(2)}}
                </template>
              </el-table-column>
            </el-table>
          </template>
          <div class="x-table-desc">总金额：{{allmoney}}</div>
          <div class="x-table-desc">验收人：{{checkname}}</div>
        </div>
        <!--  -->
        <div class="x-pro-gobtn" @click="isok" style="margin-bottom:1rem">验收</div>
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
  <script type="text/javascript" src="../script/jquery-1.11.1.min.js"></script>
  <script type="text/javascript" src="../script/swiper.min.js"></script>
	<script>
apiready = function () {
    $api.fixStatusBar($api.byId('header'));
    api.addEventListener({
        name: 'addmaterialok'
    }, function(ret, err) {

    });
    var tsupplierid = api.pageParam.supplierid;
    var tfordata = api.pageParam.fordata;
    var ttime = api.pageParam.time;
    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          tabsdata:'',
          curId:0,
          tabledata:[],
          cardsmonth:'',
          cardsmonthtoy:'',
          cardsmonthtom:'',
          tabsid:0,
          notkey:false,
          isfromindex:true,
          noget:0,
          askname:'',
          yesshow:false,
          noshow:false,
          checkname:'',
          allmoney:0,
          dialogFormVisible:false,
          form:{
            name:'',
            num:'',
          },
          thsupplierid:'',
          thfordata:{},
          thtime:'',
          isclick:true,
        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;
        that.thsupplierid = tsupplierid;
        that.thfordata = tfordata;
        that.tabledata = that.thfordata.list;
        that.checkname = that.thfordata.save_username;
        that.thtime = ttime;
        console.log(JSON.stringify(that.thfordata.list));
      
      },
      methods: {
        //提交
        isok:function(){
          let that=this;
          if(that.isclick){
            that.isclick = false
            for(var i=0;i<that.tabledata.length;i++){
              that.allmoney += that.tabledata[i].save_num*that.tabledata[i].unit_price
            }
            api.ajax({
              url:baseurl+'api/material/addAllot?sec=' + $api.getStorage('apptoken') + '&wsid=' + that.thsupplierid + '&date=' + that.thtime + '&total_price=' + that.allmoney,
              method:'post',
              data:{
                values:{
                  num_json:that.tabledata
                }
              }
            },function(ret,err){
              if(ret){
                api.hideProgress();
                console.log(JSON.stringify(ret));
                if(ret.status == 1){
                  api.toast({
                      msg: ret.msg,
                      duration: 3000,
                      location: 'bottom'
                  });
                  api.sendEvent({
                      name: 'allotchecksucc',
                      extra: {
                      
                      }
                  });
                  setTimeout(function(){
                      api.closeWin()
                  },1000)
                }else{
                  api.toast({
                      msg: ret.msg,
                      duration: 3000,
                      location: 'bottom'
                  });
                }
              }else{
                api.hideProgress();
                console.log(JSON.stringify(err));
                api.toast({
                    msg: err.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            })
          }
          
        },
        //点击列
        gotrainpro:function(val){
          // console.log(JSON.stringify(val));
          // api.openWin({
          //     name: 'intraindesc',
          //     url: './intraindesc.html',
          //     pageParam: {
          //         id: val.id,
          //         levelid:val.up_levelid
          //     }
          // });
        },
        }
    })
	}

	</script>
</body>
</html>
